package com.ruoyi.privateExamination.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.privateExamination.mapper.PrivateExaminationMapper;
import com.ruoyi.privateExamination.domain.PrivateExamination;
import com.ruoyi.privateExamination.service.IPrivateExaminationService;

/**
 * 我的体检记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-16
 */
@Service
public class PrivateExaminationServiceImpl implements IPrivateExaminationService 
{
    @Autowired
    private PrivateExaminationMapper privateExaminationMapper;

    /**
     * 查询我的体检记录
     * 
     * @param examinationId 我的体检记录主键
     * @return 我的体检记录
     */
    @Override
    public PrivateExamination selectPrivateExaminationByExaminationId(Long examinationId)
    {
        return privateExaminationMapper.selectPrivateExaminationByExaminationId(examinationId);
    }

    /**
     * 查询我的体检记录列表
     * 
     * @param privateExamination 我的体检记录
     * @return 我的体检记录
     */
    @Override
    public List<PrivateExamination> selectPrivateExaminationList(PrivateExamination privateExamination)
    {
        return privateExaminationMapper.selectPrivateExaminationList(privateExamination);
    }

    /**
     * 新增我的体检记录
     * 
     * @param privateExamination 我的体检记录
     * @return 结果
     */
    @Override
    public int insertPrivateExamination(PrivateExamination privateExamination)
    {
        // 根据examinationScore设置推荐团队id
        Long examinationScore = privateExamination.getExaminationScore();
        if (examinationScore != null) {
            if (examinationScore < 30) {
                privateExamination.setTeamId(4L);
            } else if (examinationScore >= 30 && examinationScore < 50) {
                privateExamination.setTeamId(18L);
            } else if (examinationScore >= 50 && examinationScore < 80) {
                privateExamination.setTeamId(9L);
            } else if (examinationScore >= 80 && examinationScore <= 100) {
                privateExamination.setTeamId(11L);
            }
        }
        return privateExaminationMapper.insertPrivateExamination(privateExamination);
    }

    /**
     * 修改我的体检记录
     * 
     * @param privateExamination 我的体检记录
     * @return 结果
     */
    @Override
    public int updatePrivateExamination(PrivateExamination privateExamination)
    {
        return privateExaminationMapper.updatePrivateExamination(privateExamination);
    }

    /**
     * 批量删除我的体检记录
     * 
     * @param examinationIds 需要删除的我的体检记录主键
     * @return 结果
     */
    @Override
    public int deletePrivateExaminationByExaminationIds(Long[] examinationIds)
    {
        return privateExaminationMapper.deletePrivateExaminationByExaminationIds(examinationIds);
    }

    /**
     * 删除我的体检记录信息
     * 
     * @param examinationId 我的体检记录主键
     * @return 结果
     */
    @Override
    public int deletePrivateExaminationByExaminationId(Long examinationId)
    {
        return privateExaminationMapper.deletePrivateExaminationByExaminationId(examinationId);
    }

    @Override
    public List<PrivateExamination> selectPrivateExaminationByUserId(Long userId,String teamName,Long examinationScore) {
        return privateExaminationMapper.selectPrivateExaminationByUserId(userId,teamName,examinationScore);
    }
}
